using namespace System;

namespace Havok
{
	namespace Utilities
	{
		public ref class EventError
		{
		public :

			enum class MessageType
			{
				Report = hkError::MESSAGE_REPORT,
				Warning = hkError::MESSAGE_WARNING,
				Assert = hkError::MESSAGE_ASSERT,
				Error = hkError::MESSAGE_ERROR,
			};

			ref class ErrorParameters
			{
			public :
				MessageType type;
				unsigned int id;
				String^ description;
				String^ file;
				int line;
			};

			delegate void ErrorMessageHandler(ErrorParameters^ parameters);

			static event ErrorMessageHandler^ ErrorMessage;
			
			static void RaiseEvent(ErrorParameters^ parameters)
			{
				ErrorMessage::raise(parameters);
			}
		};

		class hkEventError: public hkDefaultError
		{
		  public:
			  hkEventError():hkDefaultError(HK_NULL){};

			virtual int message(Message m, int id, const char* description, const char* file, int line)
			{
				EventError::ErrorParameters^ params = gcnew EventError::ErrorParameters(); 
				params->type = (EventError::MessageType)m;
				params->id = id;
				params->description = gcnew String(description);
				params->file = gcnew String(file);
				params->line = line;

				EventError::RaiseEvent(params);

				return 0;
			}
		};
	}
}